﻿using System;
using System.Collections.Generic;

namespace WinnerCMS.Model.Attribute
{
    /// <summary>
    /// 页面访问权限
    /// </summary>
    public class AccessAttribute : System.Attribute
    {
        /// <summary>
        /// 页面访问权限
        /// </summary>
        public AccessAttribute()
        {
            AllMacth = false;
            Codes = new List<string>();
        }
        /// <summary>
        /// 页面访问权限
        /// </summary> 
        /// <param name="codes">权限代码</param>
        public AccessAttribute(string codes)
        {
            AllMacth = false;
            Codes = new List<string>();
            Codes.AddRange(codes.Split(new[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries));
        }
        /// <summary>
        /// 页面访问权限
        /// </summary>
        /// <param name="allMacth">是否全部匹配</param>
        /// <param name="codes">权限代码</param>
        public AccessAttribute(bool allMacth, string codes)
        {
            AllMacth = allMacth;
            Codes = new List<string>();
            Codes.AddRange(codes.Split(new[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries));
        }

        /// <summary>
        /// 是否全部匹配
        /// </summary>
        public bool AllMacth { get; set; }
        /// <summary>
        /// 权限代码
        /// </summary>
        public List<string> Codes { get; set; }

        /// <summary>
        /// 是否匹配ModelId
        /// </summary>
        public bool IsMacthMID { get; set; }
    }
}
